<?php

namespace TpAmis\Traits;

trait BaseApiTrait
{

    public function BaseApiDelete($thinkUrl, array $vars = [], $suffix = true, $domain = false)
    {
        return $this->BaseApi($thinkUrl, 'delete', $vars, $suffix, $domain);
    }

    public function BaseApiPut($thinkUrl, array $vars = [], $suffix = true, $domain = false)
    {
        return $this->BaseApi($thinkUrl, 'put', $vars, $suffix, $domain);
    }

    public function BaseApiPost($thinkUrl, array $vars = [], $suffix = true, $domain = false)
    {
        return $this->BaseApi($thinkUrl, 'post', $vars, $suffix, $domain);
    }

    public function BaseApiGet($thinkUrl, array $vars = [], $suffix = true, $domain = false)
    {
        return $this->BaseApi($thinkUrl, 'get', $vars, $suffix, $domain);
    }

    public function BaseApi($thinkUrl, $method = 'post', array $vars = [], $suffix = true, $domain = false)
    {
        return amis()->BaseApi()->method($method)->url(adminUrl($thinkUrl, $vars, $suffix, $domain))->dataType('form');
    }
}